<?php
Doo::loadModelAt('base/FrbFlatChambreresBase', 'frbFlat');
Doo::loadModelAt('FrbFlatChambre', 'frbFlat');
Doo::loadModelAt('FrbFlatImmeuble', 'frbFlat');

class FrbFlatChambreres extends FrbFlatChambreresBase
{

	public static function _getAllMvtFromYear($year='', $immeuble='')
	{
		if ($year == '') {
			$year = date('Y');
		}
		$debut_annee = $year."-01-01";
		$fin_annee = $year."-12-31";

		$chambre = new FrbFlatChambre();
		$chambre->imm_fid = $immeuble;
		$options = array(
			'asc' => 'imm_fid, frbFlat_chambreres.cha_id',
			'where' => "(chr_datedeb < '$debut_annee' 
					AND ( chr_datefin = '0000-00-00' OR (chr_datefin BETWEEN '$debut_annee' AND '$fin_annee')) ) 
				OR (chr_datedeb BETWEEN '$debut_annee' AND '$fin_annee')",
		);


		return $chambre->relate('FrbFlatChambreres', $options);

	}
}